package com.csc.banking.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

@Entity
@Table(name = "TransferActions", catalog = "mydb")
public class TransferAction implements EntityObject, java.io.Serializable
{
	private Long transferActionId;
	private Customer customer;
	private TransactionAction transactionAction;
	private static final long serialVersionUID = 1L;
	
	public TransferAction() 
	{
	}
	
	public TransferAction(TransactionAction transactionAction, Customer customer) 
	{
		this.transactionAction = transactionAction;
		this.customer = customer;		
	}
	
	@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "transferAction"))
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "TransferActionId", unique = true, nullable = false)
	public Long getTransferActionId() 
	{
		return transferActionId;
	}
	
	public void setTransferActionId(Long transferActionId) 
	{
		this.transferActionId = transferActionId;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ToCustomer", nullable = false)
	public Customer getCustomer() 
	{
		return customer;
	}
	
	public void setCustomer(Customer customer) 
	{
		this.customer = customer;
	}
	
	@OneToOne(fetch = FetchType.LAZY)
	@PrimaryKeyJoinColumn
	public TransactionAction getTransactionAction() 
	{
		return transactionAction;
	}
	
	public void setTransactionAction(TransactionAction transactionAction) 
	{
		this.transactionAction = transactionAction;
	}
}
